package leecode

func convertBST(root *TreeNode) (result *TreeNode) {
	//右 中 左
	temp := 0
	result = root
	var traversal func(node *TreeNode)
	traversal = func(node *TreeNode) {
		if node == nil {
			return
		}
		traversal(node.Right)
		node.Val = node.Val + temp //中
		temp = node.Val
		traversal(node.Left)
	}
	traversal(result)
	return
}
